<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>修改密码</title>
    <script type="text/javascript">
      Ext.onReady(function(){

              Ext.apply(Ext.form.VTypes, {
                    password : function(val, field) {
                        if (field.initialPassField) {
                            var pwd = Ext.getCmp(field.initialPassField);
                            return (val == pwd.getValue());
                        }
                        return true;
                    },

                    passwordText : '密码不一致'
              });

              var changePasswordForm=new Ext.form.FormPanel({
                    width:400,
                    //labelAlign: 'top',
                    url:'/applicant/changePasswordForApplicant?id='+<%=params[:id]%>,
                    buttonAlign:'center',
                    labelAlign: 'right',  
                    autoHeight:true,
                    fileUpload: true,
                    bodyStyle: 'padding:5px',
                    labelWidth:100,
                    waitMsgTarget: true,
                    frame: true,
                    items:[{
                          layout:'column',
                          items:[{
                              columnWidth:1,
                              layout:'form',
                              labelAlign: 'left',
                              items:[{
                                  xtype:'hidden',
                                  name:'id'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '新密码',
                                  inputType:'password',
                                  name: 'password1',
                                  id:'password1',
                                  allowBlank:false,
                                  anchor:'90%' 
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '重复新密码',
                                  inputType:'password',
                                  name: 'password2',
                                  vtype: 'password',
                                  initialPassField: 'password1',
                                  allowBlank:false,
                                  anchor:'90%'
                              }]
                          }]
                     }],
                     buttons:[{
                        id:'ok',
                        text:'确定',
                        handler: function(){
                            
                            // check form value
                            if (changePasswordForm.form.isValid()) {
                              Ext.getCmp('ok').setDisabled(true);
                              changePasswordForm.form.submit({
                                method: 'post',
                                waitMsg: '正在保存新密码...',
                                success: function(result, response){
                                  if (response.result.info == "success") {
                                    //添加成功后，隐藏窗口，并刷新Grid
                                    Ext.MessageBox.alert('消息', '成功修改密码');
                                    changePasswordWin.destroy();
                                  }
                                  else {
                                    Ext.MessageBox.alert('消息', response.result.info);
                                    Ext.getCmp('ok').setDisabled(false);
                                  }
                                },
                                failure: function(result, response){
                                  Ext.MessageBox.alert('提示', result.responseText);
                                  Ext.getCmp('ok').setDisabled(false);
                                }
                              });
                            }
                            else {
                              Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                            }
                          }
                    },{
                        text:'取消',
                        handler:function(){
                            changePasswordWin.destroy();
                        }
                    }]
                });
          changePasswordForm.render('edit_auditor_form');
      })
    </script>
  </head>
  <body>
     <div id="edit_auditor_form"></div>
  </body>
</html>
